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

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

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

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

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

m.t = b
m.r = b
m.w = b
b.u = j
a.q = m
a.o = j
a.r = j
a.s = g
g.o = a
g.y = c
c.o = a
c.y = g
j.t = b
j.r = b
j.w = b
assert a.r.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

m.t = b
m.r = b
m.w = b
b.u = j
a.q = m
a.o = j
a.r = j
a.s = g
g.o = a
g.y = c
c.o = a
c.y = g
j.t = b
j.r = b
j.w = b
assert a.r.t.u.txt == "j"