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

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

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

d = A("d")
n = B("n")
e = C("e")
c = B("c")
j = A("j")

d.s = j
d.q = j
d.x = n
n.s = c
n.o = e
n.r = j
e.u = n
e.v = n
e.z = c
c.s = n
c.o = e
c.r = j
j.s = d
j.q = d
j.x = n
assert n.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
n = B("n")
e = C("e")
c = B("c")
j = A("j")

d.s = j
d.q = j
d.x = n
n.s = c
n.o = e
n.r = j
e.u = n
e.v = n
e.z = c
c.s = n
c.o = e
c.r = j
j.s = d
j.q = d
j.x = n
assert n.s.s.s.txt == "c"