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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: A = None
        self.r: C = None
        self.p: D = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
c = C("c")
h = D("h")
i = A("i")

g.s = c
g.o = h
g.q = h
g.w = h
b.x = h
b.p = h
b.u = i
b.r = c
c.t = h
h.p = c
h.x = c
h.y = b
i.s = c
i.o = h
i.q = h
i.w = h
assert c.t.y.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.o: D = None
        self.q: D = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: A = None
        self.r: C = None
        self.p: D = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
c = C("c")
h = D("h")
i = A("i")

g.s = c
g.o = h
g.q = h
g.w = h
b.x = h
b.p = h
b.u = i
b.r = c
c.t = h
h.p = c
h.x = c
h.y = b
i.s = c
i.o = h
i.q = h
i.w = h
assert c.t.y.r.t.txt == "h"