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

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

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

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

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

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

h.r = d
h.u = d
d.t = j
j.t = l
l.t = c
c.t = d
assert j.t.t.t.txt == "d"