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

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

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

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

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

h.t = k
h.r = k
h.s = f
k.v = f
k.x = f
f.s = e
b.v = h
m.v = i
e.v = f
e.x = f
i.t = e
i.r = e
i.s = f
assert k.x.s.x.s.x.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

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

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

h.t = k
h.r = k
h.s = f
k.v = f
k.x = f
f.s = e
b.v = h
m.v = i
e.v = f
e.x = f
i.t = e
i.r = e
i.s = f
assert k.x.s.x.s.x.s.v.txt == "f"