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

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

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

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

g = A("g")
e = B("e")
a = C("a")
c = D("c")
n = C("n")
b = A("b")

g.o = b
g.s = b
g.p = n
g.w = e
e.t = c
e.u = c
e.q = b
a.r = b
c.p = e
n.r = b
b.o = g
b.s = g
b.p = n
b.w = e
assert b.o.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.p: C = None
        self.w: B = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
a = C("a")
c = D("c")
n = C("n")
b = A("b")

g.o = b
g.s = b
g.p = n
g.w = e
e.t = c
e.u = c
e.q = b
a.r = b
c.p = e
n.r = b
b.o = g
b.s = g
b.p = n
b.w = e
assert b.o.s.p.txt == "n"