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

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

g.y = f
g.t = f
g.u = c
g.z = c
b.x = f
b.u = f
b.y = m
b.p = j
i.v = f
i.y = m
i.z = m
f.z = i
c.y = f
c.t = f
c.u = g
c.z = g
e.x = f
e.u = f
e.y = m
e.p = j
j.x = f
j.u = f
j.y = m
j.p = b
m.v = f
m.y = i
m.z = i
assert g.u.z.u.z.y.z.z.txt == "m"