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

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

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

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

m = A("m")
j = B("j")
b = C("b")
i = D("i")
g = B("g")
a = D("a")

m.r = b
m.s = b
j.s = g
j.u = g
b.t = j
b.v = i
b.q = i
b.x = a
i.p = a
i.z = a
i.o = a
i.r = b
g.s = j
g.u = j
a.p = i
a.z = i
a.o = i
a.r = b
assert j.u.u.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: C = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
b = C("b")
i = D("i")
g = B("g")
a = D("a")

m.r = b
m.s = b
j.s = g
j.u = g
b.t = j
b.v = i
b.q = i
b.x = a
i.p = a
i.z = a
i.o = a
i.r = b
g.s = j
g.u = j
a.p = i
a.z = i
a.o = i
a.r = b
assert j.u.u.s.s.txt == "j"