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

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

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

c = A("c")
d = B("d")
g = C("g")
j = B("j")
h = C("h")
a = A("a")
n = B("n")

c.r = n
c.q = a
c.o = g
d.r = n
g.o = h
g.w = h
g.x = n
j.r = n
h.o = g
h.w = g
h.x = d
a.r = j
a.q = c
a.o = h
n.r = j
assert a.o.w.x.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: A = None
        self.o: C = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
g = C("g")
j = B("j")
h = C("h")
a = A("a")
n = B("n")

c.r = n
c.q = a
c.o = g
d.r = n
g.o = h
g.w = h
g.x = n
j.r = n
h.o = g
h.w = g
h.x = d
a.r = j
a.q = c
a.o = h
n.r = j
assert a.o.w.x.r.r.txt == "n"