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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: C = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
l = C("l")
f = D("f")
m = A("m")
j = C("j")
a = A("a")
e = A("e")

i.x = m
g.w = j
g.r = j
g.x = l
l.z = f
l.x = g
f.u = g
f.w = g
f.v = e
f.q = m
m.x = i
j.z = f
j.x = g
a.x = e
e.x = i
assert g.x.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: C = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
l = C("l")
f = D("f")
m = A("m")
j = C("j")
a = A("a")
e = A("e")

i.x = m
g.w = j
g.r = j
g.x = l
l.z = f
l.x = g
f.u = g
f.w = g
f.v = e
f.q = m
m.x = i
j.z = f
j.x = g
a.x = e
e.x = i
assert g.x.z.q.x.txt == "i"