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

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

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

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

f = A("f")
l = B("l")
c = C("c")
d = D("d")
n = A("n")
h = D("h")

f.y = h
f.q = l
l.o = f
l.x = h
c.x = n
c.q = n
c.y = l
d.s = n
d.v = n
d.u = c
d.x = l
n.y = h
n.q = l
h.s = f
h.v = f
h.u = c
h.x = l
assert n.y.u.x.y.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: B = None
        self.txt = txt

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

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

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

f = A("f")
l = B("l")
c = C("c")
d = D("d")
n = A("n")
h = D("h")

f.y = h
f.q = l
l.o = f
l.x = h
c.x = n
c.q = n
c.y = l
d.s = n
d.v = n
d.u = c
d.x = l
n.y = h
n.q = l
h.s = f
h.v = f
h.u = c
h.x = l
assert n.y.u.x.y.u.x.txt == "n"