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

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

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

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

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

g.r = a
g.t = l
l.p = c
a.s = m
a.p = m
a.o = l
e.x = d
e.q = c
b.s = a
b.p = m
b.o = l
j.r = b
j.t = l
c.p = l
d.x = e
d.q = c
m.s = a
m.p = b
m.o = c
assert e.x.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: B = None
        self.txt = txt

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

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

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

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

g.r = a
g.t = l
l.p = c
a.s = m
a.p = m
a.o = l
e.x = d
e.q = c
b.s = a
b.p = m
b.o = l
j.r = b
j.t = l
c.p = l
d.x = e
d.q = c
m.s = a
m.p = b
m.o = c
assert e.x.x.q.txt == "c"