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

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

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

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

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

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

b.r = j
b.u = j
a.w = k
f.s = j
k.w = a
k.v = b
k.x = f
j.p = a
l.r = j
l.u = j
h.r = j
h.u = j
assert j.p.w.w.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.u: E = None
        self.txt = txt

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

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

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

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

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

b.r = j
b.u = j
a.w = k
f.s = j
k.w = a
k.v = b
k.x = f
j.p = a
l.r = j
l.u = j
h.r = j
h.u = j
assert j.p.w.w.w.x.txt == "f"