class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.p: C = None
        self.s: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: C = None
        self.v: C = None
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: B = None
        self.s: A = None
        self.p: B = None
        self.txt = txt

c = A("c")
i = B("i")
e = C("e")
g = D("g")
m = C("m")
n = D("n")
b = C("b")

c.u = n
i.o = c
i.s = c
i.t = e
i.p = b
e.x = i
e.p = m
e.v = m
e.y = n
g.z = c
g.s = c
g.r = i
g.p = i
m.x = i
m.p = e
m.v = b
m.y = n
n.z = c
n.s = c
n.r = i
n.p = i
b.x = i
b.p = e
b.v = e
b.y = g
assert g.s.u.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.p: C = None
        self.s: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: C = None
        self.v: C = None
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: B = None
        self.s: A = None
        self.p: B = None
        self.txt = txt

c = A("c")
i = B("i")
e = C("e")
g = D("g")
m = C("m")
n = D("n")
b = C("b")

c.u = n
i.o = c
i.s = c
i.t = e
i.p = b
e.x = i
e.p = m
e.v = m
e.y = n
g.z = c
g.s = c
g.r = i
g.p = i
m.x = i
m.p = e
m.v = b
m.y = n
n.z = c
n.s = c
n.r = i
n.p = i
b.x = i
b.p = e
b.v = e
b.y = g
assert g.s.u.s.u.s.txt == "c"