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

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

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

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

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

j = A("j")
f = B("f")
d = C("d")
c = D("c")
g = E("g")
h = C("h")

j.r = f
j.x = c
f.p = g
d.y = h
d.w = c
d.t = f
c.u = d
g.y = c
h.y = d
h.w = c
h.t = f
assert g.y.u.y.w.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.txt = txt

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

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

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

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

j = A("j")
f = B("f")
d = C("d")
c = D("c")
g = E("g")
h = C("h")

j.r = f
j.x = c
f.p = g
d.y = h
d.w = c
d.t = f
c.u = d
g.y = c
h.y = d
h.w = c
h.t = f
assert g.y.u.y.w.u.t.txt == "f"