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

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

d = A("d")
c = B("c")
l = B("l")
g = A("g")
b = B("b")
h = A("h")
j = A("j")

d.o = g
d.r = b
c.t = j
l.t = h
g.o = j
g.r = b
b.t = j
h.o = g
h.r = b
j.o = h
j.r = c
assert d.o.o.o.o.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: B = None
        self.txt = txt

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

d = A("d")
c = B("c")
l = B("l")
g = A("g")
b = B("b")
h = A("h")
j = A("j")

d.o = g
d.r = b
c.t = j
l.t = h
g.o = j
g.r = b
b.t = j
h.o = g
h.r = b
j.o = h
j.r = c
assert d.o.o.o.o.o.r.txt == "c"