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

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

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

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

j = A("j")
c = B("c")
h = C("h")
n = D("n")

j.u = c
j.y = n
c.u = n
c.v = j
h.y = j
n.o = h
assert h.y.u.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: D = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
h = C("h")
n = D("n")

j.u = c
j.y = n
c.u = n
c.v = j
h.y = j
n.o = h
assert h.y.u.u.o.txt == "h"