class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

h = A("h")
l = B("l")
i = C("i")
j = D("j")
b = E("b")
c = C("c")

h.r = j
h.x = j
l.t = h
l.v = h
l.u = h
i.r = h
j.t = l
b.w = l
b.t = j
c.r = h
assert h.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

h = A("h")
l = B("l")
i = C("i")
j = D("j")
b = E("b")
c = C("c")

h.r = j
h.x = j
l.t = h
l.v = h
l.u = h
i.r = h
j.t = l
b.w = l
b.t = j
c.r = h
assert h.x.t.t.txt == "h"