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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: B = None
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
l = C("l")
c = D("c")

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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: B = None
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
l = C("l")
c = D("c")

g.s = l
g.w = c
g.y = c
b.u = c
b.s = l
l.v = c
l.o = b
l.t = b
l.p = g
c.w = l
c.y = l
assert g.w.w.p.txt == "g"