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

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

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

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

f = A("f")
k = B("k")
j = C("j")
l = D("l")
i = D("i")
h = B("h")
c = B("c")
b = C("b")

f.u = j
k.x = c
k.p = c
k.u = l
k.v = f
j.u = b
j.v = b
j.x = c
l.t = i
l.x = i
l.r = b
i.t = l
i.x = l
i.r = j
h.x = k
h.p = k
h.u = l
h.v = f
c.x = k
c.p = k
c.u = i
c.v = f
b.u = j
b.v = j
b.x = h
assert k.u.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
j = C("j")
l = D("l")
i = D("i")
h = B("h")
c = B("c")
b = C("b")

f.u = j
k.x = c
k.p = c
k.u = l
k.v = f
j.u = b
j.v = b
j.x = c
l.t = i
l.x = i
l.r = b
i.t = l
i.x = l
i.r = j
h.x = k
h.p = k
h.u = l
h.v = f
c.x = k
c.p = k
c.u = i
c.v = f
b.u = j
b.v = j
b.x = h
assert k.u.t.x.x.txt == "i"