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

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

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

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

h = A("h")
m = B("m")
i = C("i")
f = D("f")
k = A("k")

h.r = i
h.o = k
h.p = f
m.y = h
i.x = k
i.u = k
i.r = m
f.z = h
f.y = h
f.o = k
k.r = i
k.o = h
k.p = f
assert k.o.r.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: A = None
        self.p: D = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
i = C("i")
f = D("f")
k = A("k")

h.r = i
h.o = k
h.p = f
m.y = h
i.x = k
i.u = k
i.r = m
f.z = h
f.y = h
f.o = k
k.r = i
k.o = h
k.p = f
assert k.o.r.r.y.r.txt == "i"