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

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

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

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

c = A("c")
j = B("j")
f = C("f")
e = D("e")
k = A("k")
g = D("g")

c.x = f
c.t = k
c.w = j
j.s = f
f.z = j
e.p = g
e.r = g
k.x = f
k.t = c
k.w = j
g.p = e
g.r = e
assert f.z.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: A = None
        self.w: B = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
f = C("f")
e = D("e")
k = A("k")
g = D("g")

c.x = f
c.t = k
c.w = j
j.s = f
f.z = j
e.p = g
e.r = g
k.x = f
k.t = c
k.w = j
g.p = e
g.r = e
assert f.z.s.z.s.z.txt == "j"