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

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

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

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

e = A("e")
j = B("j")
k = C("k")
c = D("c")
n = B("n")

e.r = k
e.w = c
e.y = c
e.u = n
j.v = n
k.u = e
c.z = k
n.v = j
assert j.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.w: D = None
        self.y: D = None
        self.u: B = None
        self.txt = txt

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

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

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

e = A("e")
j = B("j")
k = C("k")
c = D("c")
n = B("n")

e.r = k
e.w = c
e.y = c
e.u = n
j.v = n
k.u = e
c.z = k
n.v = j
assert j.v.v.v.v.v.txt == "n"