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

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

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

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

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

c.t = k
c.v = k
n.r = b
j.t = n
b.u = k
b.q = n
k.t = c
k.v = c
assert n.r.u.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: A = None
        self.txt = txt

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

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

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

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

c.t = k
c.v = k
n.r = b
j.t = n
b.u = k
b.q = n
k.t = c
k.v = c
assert n.r.u.t.t.t.txt == "c"