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

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

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

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

f = A("f")
e = B("e")
m = C("m")
h = D("h")
l = D("l")
d = C("d")
i = A("i")
j = D("j")
c = B("c")
n = D("n")

f.r = e
f.t = i
f.w = d
f.o = l
e.s = f
e.u = c
e.v = d
e.x = j
m.x = d
m.p = i
m.z = h
h.x = c
l.x = c
d.x = m
d.p = f
d.z = n
i.r = e
i.t = f
i.w = d
i.o = h
j.x = c
c.s = i
c.u = e
c.v = m
c.x = n
n.x = c
assert l.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: A = None
        self.w: C = None
        self.o: D = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
m = C("m")
h = D("h")
l = D("l")
d = C("d")
i = A("i")
j = D("j")
c = B("c")
n = D("n")

f.r = e
f.t = i
f.w = d
f.o = l
e.s = f
e.u = c
e.v = d
e.x = j
m.x = d
m.p = i
m.z = h
h.x = c
l.x = c
d.x = m
d.p = f
d.z = n
i.r = e
i.t = f
i.w = d
i.o = h
j.x = c
c.s = i
c.u = e
c.v = m
c.x = n
n.x = c
assert l.x.x.x.txt == "c"