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

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

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

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

c = A("c")
g = B("g")
n = C("n")
k = D("k")
f = C("f")
e = D("e")

c.y = k
g.u = n
g.y = c
g.r = c
n.o = c
n.p = g
k.r = e
k.x = n
k.s = n
k.o = n
f.o = c
f.p = g
e.r = k
e.x = f
e.s = n
e.o = n
assert e.x.p.r.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
n = C("n")
k = D("k")
f = C("f")
e = D("e")

c.y = k
g.u = n
g.y = c
g.r = c
n.o = c
n.p = g
k.r = e
k.x = n
k.s = n
k.o = n
f.o = c
f.p = g
e.r = k
e.x = f
e.s = n
e.o = n
assert e.x.p.r.y.s.txt == "n"