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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: D = None
        self.p: D = None
        self.y: D = None
        self.txt = txt

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

b.q = c
b.o = c
b.r = m
b.z = f
m.t = c
m.x = i
c.r = m
c.x = m
c.o = k
c.v = b
f.q = c
f.o = k
f.p = k
f.y = i
k.q = c
k.o = f
k.p = f
k.y = f
i.q = c
i.o = f
i.p = f
i.y = k
j.q = c
j.o = c
j.r = m
j.z = k
assert j.z.o.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: B = None
        self.o: C = None
        self.z: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: D = None
        self.p: D = None
        self.y: D = None
        self.txt = txt

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

b.q = c
b.o = c
b.r = m
b.z = f
m.t = c
m.x = i
c.r = m
c.x = m
c.o = k
c.v = b
f.q = c
f.o = k
f.p = k
f.y = i
k.q = c
k.o = f
k.p = f
k.y = f
i.q = c
i.o = f
i.p = f
i.y = k
j.q = c
j.o = c
j.r = m
j.z = k
assert j.z.o.o.y.o.txt == "k"