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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: C = None
        self.x: C = None
        self.txt = txt

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

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

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

c.r = j
c.t = n
k.q = c
k.s = j
k.x = j
j.v = k
j.z = k
n.o = k
n.z = j
assert c.r.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: C = None
        self.x: C = None
        self.txt = txt

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

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

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

c.r = j
c.t = n
k.q = c
k.s = j
k.x = j
j.v = k
j.z = k
n.o = k
n.z = j
assert c.r.v.q.txt == "c"