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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: C = None
        self.s: D = None
        self.v: B = None
        self.txt = txt

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

i = A("i")
k = B("k")
a = C("a")
e = D("e")
g = C("g")
j = B("j")

i.x = e
k.z = i
k.p = e
a.r = g
a.u = g
a.s = e
a.v = k
e.s = i
g.r = a
g.u = a
g.s = e
g.v = k
j.z = i
j.p = e
assert a.r.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: C = None
        self.s: D = None
        self.v: B = None
        self.txt = txt

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

i = A("i")
k = B("k")
a = C("a")
e = D("e")
g = C("g")
j = B("j")

i.x = e
k.z = i
k.p = e
a.r = g
a.u = g
a.s = e
a.v = k
e.s = i
g.r = a
g.u = a
g.s = e
g.v = k
j.z = i
j.p = e
assert a.r.u.s.txt == "e"