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

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

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

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

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

f = A("f")
a = B("a")
j = C("j")
b = D("b")
h = E("h")
c = D("c")

f.y = b
a.r = f
a.u = h
a.x = j
j.t = h
b.w = h
h.y = a
h.s = a
h.r = b
c.w = h
assert a.x.t.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

f = A("f")
a = B("a")
j = C("j")
b = D("b")
h = E("h")
c = D("c")

f.y = b
a.r = f
a.u = h
a.x = j
j.t = h
b.w = h
h.y = a
h.s = a
h.r = b
c.w = h
assert a.x.t.r.w.txt == "h"