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

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: C = None
        self.z: C = None
        self.w: A = 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: A = None
        self.txt = txt

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

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

j.t = f
c.r = j
c.w = j
c.x = k
c.z = k
k.s = b
f.w = j
b.r = c
b.z = c
b.s = c
b.v = f
assert b.z.r.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: C = None
        self.z: C = None
        self.w: A = 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: A = None
        self.txt = txt

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

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

j.t = f
c.r = j
c.w = j
c.x = k
c.z = k
k.s = b
f.w = j
b.r = c
b.z = c
b.s = c
b.v = f
assert b.z.r.t.w.txt == "j"